# -*- coding: utf-8 -*-
# @Time : 2021/9/12 19:05
# @Author : hello
# @Email : xxx@gmail.com
# @File : addcusbx_page.py
# @Project : crm

from selenium.webdriver.common.by import By
from time import sleep
from selenium.webdriver.support.select import Select
from page.crmtest.addcusbases_page import CusBases

"""验证添加功能-必填项输入框（客户名称）合法输入，其他输入框为空"""

class AddCusBx(CusBases):

    sylxr = (By.ID, 'contacts_name')
    js_khhy = "document.getElementById('industry').removeAttribute('checked')"
    js_companyxz = "document.getElementById('ownership2').removeAttribute('checked')"
    js_pf = "document.getElementById('rating1').removeAttribute('checked')"

    def delnotbx(self):
        """清空非必选项"""
        self.driver.find_element(*self.fzr).clear()
        self.driver.find_element(*self.sylxr).clear()
        sleep(2)
        self.driver.execute_script(self.js_khhy)
        self.driver.execute_script(self.js_companyxz)
        self.driver.execute_script(self.js_pf)
        khxx_locator = self.driver.find_element(*self.khxxly)
        Select(khxx_locator).select_by_visible_text('--请选择--')
        self.driver.find_element(*self.yb).clear()
        sleep(2)
        yearmy_locator = self.driver.find_element(*self.yearmy)
        Select(yearmy_locator).select_by_visible_text('--请选择--')
        sleep(2)
        x_locator = self.driver.find_element(*self.adress_x)
        Select(x_locator).select_by_visible_text('--请选择省份--')
        s_locator = self.driver.find_element(*self.adress_s)
        Select(s_locator).select_by_visible_text('--请选择城市--')
        q_locator = self.driver.find_element(*self.adress_q)
        Select(q_locator).select_by_visible_text('--请选择地区--')
        self.driver.find_element(*self.jd).clear()
        yg_locator = self.driver.find_element(*self.fzyg)
        Select(yg_locator).select_by_visible_text('--请选择--')
        self.driver.find_element(*self.fzbz).clear()